﻿Namespace DataAccess
    Public Class Definitions
        Inherits DataTable

        Sub New()

            MyBase.New()
            Me.Columns.Add("Code")
            Me.Columns.Add("Name")
            Me.Columns.Add("CodePage")

            Me.Rows.Add(New String() {"ar", "Arabic", 708})
            Me.Rows.Add(New String() {"zh-CN", "Chinese (Simplified)", 936})
            Me.Rows.Add(New String() {"zh-TW", "Chinese (Traditional)", 950})
            Me.Rows.Add(New String() {"nl", "Dutch", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"en", "English", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"fr", "French", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"de", "German", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"el", "Greek", 1253})
            Me.Rows.Add(New String() {"id", "Indonesian", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"it", "Italian", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"ja", "Japanese", 932})
            Me.Rows.Add(New String() {"ko", "Korean", 949})
            Me.Rows.Add(New String() {"fa", "Persian", 1256})
            Me.Rows.Add(New String() {"pl", "Polish", 28592})
            Me.Rows.Add(New String() {"ro", "Romanian", System.Text.Encoding.UTF8.CodePage})
            Me.Rows.Add(New String() {"ru", "Russian", 20866})
            Me.Rows.Add(New String() {"es", "Spanish", 65000})
            Me.Rows.Add(New String() {"tr", "Turkish", 65000})
            Me.Rows.Add(New String() {"vi", "Vietnamese", 65000})


        End Sub
        Public Function GetNameByCode(ByVal code As String) As String
            Dim drArray As DataRow()
            drArray = Me.Select("Code='" + code + "'")
            If drArray IsNot Nothing AndAlso drArray.Length > 0 Then
                Return drArray(0)("Name")
            End If
            Return String.Empty
        End Function
        Public Function GetCodeByName(ByVal Name As String) As String
            Dim drArray As DataRow()
            drArray = Me.Select("Name='" + Name + "'")
            If drArray IsNot Nothing AndAlso drArray.Length > 0 Then
                Return drArray(0)("Code")
            End If
            Return String.Empty
        End Function

        Public Function GetCodePageByCode(ByVal code As String) As Integer
            Dim drArray As DataRow()
            drArray = Me.Select("Code='" + code + "'")
            If drArray IsNot Nothing AndAlso drArray.Length > 0 Then
                Return drArray(0)("CodePage")
            End If
            Return System.Text.Encoding.Unicode.CodePage
        End Function

    End Class
End Namespace